import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Test10 {

	public static void main(String[] args) {
		
		Test10 a = new Test10();
		a.test2();
	}

	public Date getGmtDate() {
		Calendar calendar = Calendar.getInstance();
		int offset = calendar.get(Calendar.ZONE_OFFSET) / 3600000
				+ calendar.get(Calendar.DST_OFFSET) / 3600000;
		calendar.add(Calendar.HOUR, -offset);
		Date date = calendar.getTime();

		return date;
	}

	public void mm() throws Exception {
		Calendar processDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
		System.out.println("date= " + processDate.getTime());
		System.out.println(processDate.get(Calendar.YEAR) + "-"
				+ (processDate.get(Calendar.MONTH) + 1) + "-" + processDate.get(Calendar.DATE));
		String d = "2012-10-10";

		processDate.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(d));
		System.out.println("date= " + processDate.getTime());
		System.out.println(processDate.get(Calendar.YEAR) + "-"
				+ (processDate.get(Calendar.MONTH) + 1) + "-" + processDate.get(Calendar.DATE));


		Calendar date = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
		System.out.println("date= " + date.getTime());
		date.set(Calendar.MONTH, 0);
		System.out.println("date= " + date.getTime());
		
		// processDate.set(Calendar.YEAR, Integer.parseInt(d.substring(0, 4)));
		// processDate.set(Calendar.MONTH, Integer.parseInt(d.substring(5,
		// 7))-1);
		// processDate.set(Calendar.DAY_OF_MONTH,
		// Integer.parseInt(args[1].substring(8)));
		// processDate.set(Calendar.HOUR_OF_DAY, 0);
		// processDate.set(Calendar.MINUTE, 0);
		// processDate.set(Calendar.SECOND, 0);

		System.out.println();
		// Here we assume the args[1] is one GMT date, so need not to convert
		// again.
	}

	public void test2(){
		
		long a = 100L;
		long b = 30L;
		System.out.println(a/b);
		System.out.println(a%b);
		
	}
	public void test(){

		long a =10;
		int b = 3;
		System.out.println(10/3);
		System.out.println(10%3);
		Timestamp   tm   =   new   Timestamp(1346770803974L);
		
		
		StringBuffer sql = new StringBuffer();
		sql.append(" select ifnull(o.msgid,r.msgid)msgid,ifNull(r.split,1) split,");
		sql.append(" o.TimeMark,ifnull(r.O_Operator,o.O_Operator)O_Operator,ifnull(r.OSsID,o.ossid)ossid,");
		sql.append(" ifnull(r.o_a2p,o.O_A2P)Oa2p,ifnull(r.R_A2P,0)R_A2P,ifnull(r.RSsID,0) Rssid,");
		sql.append(" ifnull(r.R_Operator,0)R_Operator,o.InMsgID,ifnull(r.OutMsgID,0)OutMsgID,o.MessageSize InMessageSize,r.MessageSize OutMessageSize,o.SenderAddresses,");
		sql.append(" ifnull(o.RecipientAddresses,'0')RecipientAddresses,o.ContentType,o.StatusCode instatecode,");
		sql.append(" r.StatusCode outstatecode,o.CDRTime incdrtime, ifnull(r.CDRTime,0) ");
		sql.append(" from cdr_temp o");
		sql.append(" left join  cdr_temp r");
		sql.append(" on o.msgid = r.msgid  ");
//			sql.append(" and r.CDRType ='OUT_SUBMIT' and o.CDRType ='IN_SUBMIT' ");
//			sql.append(" where o.CDRType ='IN_SUBMIT' and o.sortid>? and o.sortid<=? ");
			
			sql.append(" and r.CDRType ='OUT_DELI_REP' and o.CDRType ='IN_DELI_REP' ");
			sql.append(" where o.CDRType ='IN_DELI_REP' and o.sortid>? and o.sortid<=?   ");
		sql.append(" and o.msgRefNum is null  and r.msgRefNum is null ");
		sql.append(" union ");
		sql.append(" select ifnull(r.msgid,o.msgid)msgid,ifNull(r.split,1) split,");
		sql.append(" r.TimeMark,ifnull(r.O_Operator,o.O_Operator)O_Operator,ifnull(r.OSsID,o.ossid)ossid,");
		sql.append(" ifnull(r.o_a2p,o.O_A2P)Oa2p,r.R_A2P,r.RSsID,");
		sql.append(" r.R_Operator,o.InMsgID,ifnull(r.OutMsgID,0)OutMsgID,o.MessageSize InMessageSize,r.MessageSize OutMessageSize,r.SenderAddresses,");
		sql.append(" r.RecipientAddresses,ifnull(o.ContentType,r.ContentType) ContentType,o.StatusCode instatecode,");
		sql.append(" r.StatusCode outstatecode,ifnull(o.CDRTime,0) incdrtime, r.CDRTime outcdrtime");
		sql.append(" from cdr_temp r");
		sql.append(" left join  cdr_temp o");
		sql.append(" on o.msgid = r.msgid ");
//			sql.append(" and r.CDRType ='OUT_SUBMIT' and o.CDRType ='IN_SUBMIT' ");
//			sql.append(" where r.CDRType ='OUT_SUBMIT' and r.sortid>? and r.sortid<=? ");
			sql.append(" and r.CDRType ='OUT_DELI_REP' and o.CDRType ='IN_DELI_REP' ");
			sql.append(" where r.CDRType ='OUT_DELI_REP' and r.sortid>? and r.sortid<=?  ");
		sql.append(" and o.msgRefNum is null  and r.msgRefNum is null ");
		
		
		
		System.out.println(sql.toString());
		
		
	}
	public void offset() {
		Calendar myCalendar = new GregorianCalendar();

		int gmtOffset = myCalendar.get(Calendar.ZONE_OFFSET);
		System.out.println("GMT Offset is " + gmtOffset + " milliseonds (or "
				+ TimeUnit.HOURS.convert(gmtOffset, TimeUnit.MILLISECONDS) + " hours)");

		Calendar myCalendar2 = new GregorianCalendar();
		TimeZone timeZone = myCalendar2.getTimeZone();
		int gmtOffset2 = timeZone.getRawOffset();
		System.out.println("GMT Offset is " + gmtOffset2 + " milliseonds (or "
				+ TimeUnit.HOURS.convert(gmtOffset2, TimeUnit.MILLISECONDS) + " hours)");
	}
	
	private void process(){
		Pattern p = Pattern.compile("mms.mnc(\\d{3}).mcc(\\d{3}).gprs");
		Matcher m = p.matcher("mms.mnc123.mcc456.gprs");
		if (m.matches()) {
			m.reset();
			while (m.find()) {
				System.out.println(m.group(1));
				System.out.println(m.group(2));
				
			}
		}
	}
}